import time

from selenium.webdriver.common.by import By

from base.page_base import BasePage


class LimitPage(BasePage):
    def __init__(self, driver):
        super().__init__(driver)
        self.change = (By.XPATH, '//*[@id="mlayout"]/div[2]/div[2]/div[1]/a/em')
        self.quota = (By.XPATH, '//*[@id="mlayout"]/div[2]/div[2]/div[3]/div[2]/dl/dd[4]/a')
        self.amount_account = (By.ID, "amount_account")
        self.remark = (By.XPATH, '//*[@id="mamountapply"]/div[3]/textarea')
        self.verifycode = (By.XPATH, '//*[@id="verifycode"]')
        self.submit = (By.XPATH, '//*[@id="mamountapply"]/div[5]/input')
        self.success_result = (By.XPATH, '//*[@id="amount_list"]/tr/td[6]')

    def limit(self,amount,remark,verifycode):
        self.base_click(self.change)
        self.base_click(self.quota)
        self.base_input(self.amount_account, amount)
        self.base_input(self.remark, remark)
        self.base_input(self.verifycode, verifycode)
        self.base_click(self.submit)

    def get_success_result(self):
        result = self.fd_element(self.success_result).text
        return result


